*** REPLICATION TOOLKIT ***

* AUTHORS: CIMINELLI DUVAL FURCERI 

* ARTICLE: EMPLOYMENT PROTECTION DEREGULATION AND LABOR SHARES IN ADVANCED ECONOMIES 

* JOURNAL: REVIEW OF ECONOMICS AND STATISTICS

* OUTPUT: TABLE G8 (Online Appendix)

***************************

cd ""

putexcel set "Tables/G8", modify 

global horizon 6 

************ PREPARE DATASET **********

run "Do files/Clean dataset"

** Create control variables
* Relative investment price (ratio of investment to capital price level)
gen c1 = pl_i/pl_c
* Trade opennes (share of import plus share of export)
gen c2 = csh_x-csh_m
* Union Density changes
gen c3 = (oecd_UD-l.oecd_UD)
* Unemployment benefits 
gen c4 = Unemploymentbenefitsoverall
* Unemployment rate
gen c5 = l.unr

* Interact controls with industry characteristics 
forvalues c = 1 / 5 {
gen c`c's2 = c`c'*layoff_rate
gen c`c's3 = c`c'*epsilon1
gen c`c's4 = c`c'*layoff_rate*epsilon1
}

************ ANALYSIS **********

forvalues s = 2/4 {
mat mat`s' = J(18,$horizon,.)

* Baseline
forvalues i= 1/$horizon {
quietly reghdfe  Y`i' r`s' l1Y l2Y l3Y l4Y l1r`s' l2r`s' l3r`s' l4r`s' t`s' ${f`i'`s'}, absorb(id_cross_section i.year#id_country i.year#id_industry) cluster(ifscode year) nocons
matrix results = r(table)
mat mat`s'[1,`i'] = results[1,1]
mat mat`s'[2,`i'] = results[2,1]
mat mat`s'[3,`i'] = results[4,1]
* Relative investment price 
quietly reghdfe  Y`i' r`s' c1s`s' l1Y l2Y l3Y l4Y l1r`s' l2r`s' l3r`s' l4r`s' t`s' ${f`i'`s'}, absorb(id_cross_section i.year#id_country i.year#id_industry) cluster(ifscode year) nocons
matrix results = r(table)
mat mat`s'[4,`i'] = results[1,1]
mat mat`s'[5,`i'] = results[2,1]
mat mat`s'[6,`i'] = results[4,1]
* Trade Openness 
quietly reghdfe  Y`i' r`s' c2s`s' l1Y l2Y l3Y l4Y l1r`s' l2r`s' l3r`s' l4r`s' t`s' ${f`i'`s'}, absorb(id_cross_section i.year#id_country i.year#id_industry) cluster(ifscode year) nocons
matrix results = r(table)
mat mat`s'[7,`i'] = results[1,1]
mat mat`s'[8,`i'] = results[2,1]
mat mat`s'[9,`i'] = results[4,1]
* Change in Union Density
quietly reghdfe  Y`i' r`s' c3s`s' l1Y l2Y l3Y l4Y l1r`s' l2r`s' l3r`s' l4r`s' t`s' ${f`i'`s'}, absorb(id_cross_section i.year#id_country i.year#id_industry) cluster(ifscode year) nocons
matrix results = r(table)
mat mat`s'[10,`i'] = results[1,1]
mat mat`s'[11,`i'] = results[2,1]
mat mat`s'[12,`i'] = results[4,1]
* Reform to unemployment benefits
quietly reghdfe  Y`i' r`s' c4s`s' l1Y l2Y l3Y l4Y l1r`s' l2r`s' l3r`s' l4r`s' t`s' ${f`i'`s'}, absorb(id_cross_section i.year#id_country i.year#id_industry) cluster(ifscode year) nocons
matrix results = r(table)
mat mat`s'[13,`i'] = results[1,1]
mat mat`s'[14,`i'] = results[2,1]
mat mat`s'[15,`i'] = results[4,1]
* Controlling for unemployment rate
quietly reghdfe  Y`i' r`s' c5s`s' l1Y l2Y l3Y l4Y l1r`s' l2r`s' l3r`s' l4r`s' t`s' ${f`i'`s'}, absorb(id_cross_section i.year#id_country i.year#id_industry) cluster(ifscode year) nocons
matrix results = r(table)
mat mat`s'[16,`i'] = results[1,1]
mat mat`s'[17,`i'] = results[2,1]
mat mat`s'[18,`i'] = results[4,1]
}
}

************ SAVE OUTPUT **********

putexcel B4=matrix(mat2)
putexcel B24=matrix(mat3)
putexcel B44=matrix(mat4)
